﻿using System;

public class Array
{
   public static void Main()
   {
       int[] nums = { 1, 2, 3, 4, 5 };//一个整数数组

       int max = nums[0];
       int min = nums[0];
       int sum = 0;

       for (int i = 0; i < nums.Length; i++)
       {
           if (nums[i] > max)
           {
               max = nums[i];//max
           }

           if (nums[i] < min)
           {
               min = nums[i];//min
           }

           sum += nums[i];//总和
       }

       double average = (double)sum / nums.Length;//平均值

       Console.WriteLine("数组的最大值为：" + max);
       Console.WriteLine("数组的最小值为：" + min);
       Console.WriteLine("数组的平均值为：" + average);
       Console.WriteLine("数组所有元素的和为：" + sum);
   }
}
